Guest User

Untitled

a guest
Jul 17th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.41 KB | None | 0 0
  1. Container = function( el ){
  2. var
  3. me = {
  4. el:el,
  5. win: $( window )
  6. }
  7. return me
  8. }
  9.  
  10. Panel = function( el, params ){
  11. var me = Container( el ),
  12. //dom elements
  13. general_block = el.children( '.general_block' ),
  14. block = general_block.children( '.block' ),
  15. block = general_block.children( '.block' ),
  16. block_head = block.children( '.block_head' ),
  17. from = params.from,
  18. to = params.to,
  19. head = el.children( '.head' ),
  20. show_hide_panel = head.children( '.show_hide_panel' ),
  21. show_hide_block = block_head.children( '.show_hide_block' ),
  22. controls = block.children( '.controls' ),
  23. max_height = null,
  24. //--
  25.  
  26. bottom = me.win.height() - from.offset().top,
  27. calc_max_heigth = function(){
  28. max_height = me.win.height() - ( to.offset().top + to.innerHeight() + bottom + head.innerHeight() )
  29. general_block.css( { 'max-height': max_height } )
  30. }
  31.  
  32. //GLOBAL
  33. me.show_block = function( c ){
  34. var em = general_block.children( '.block.' + c )
  35. em.removeClass('hidden')
  36. em.show()
  37. }
  38. me.hide_block = function( c ){
  39. var em = general_block.children( '.block.' + c )
  40. em.addClass('hidden')
  41. em.hide()
  42. }
  43. me.head_by_class = function( c ){
  44. return general_block.children( '.block.' + c ).children( '.block_head' )
  45. }
  46. me.checkbox_by_block_class = function( c ){
  47. return me.head_by_class( c ).children( '.name' ).children( '.tile_layer_visible_checkbox' )
  48. }
  49. me.is_all_block_hidden = function(){
  50. return block.filter( '.hidden' ).length == block.length
  51. }
  52. me.init = function(){
  53. calc_max_heigth()
  54. el.css( { visibility: 'visible', display: 'none' } )
  55. el.fadeIn(3000)
  56. }
  57.  
  58. me.general_block = function(){ return general_block }
  59. me.block_head = function(){ return block_head }
  60. me.controls = function(){ return controls }
  61. me.from = function(){ return from }
  62. me.bottom = function(){ return bottom }
  63. //--
  64.  
  65. //bindings
  66.  
  67.  
  68. show_hide_panel.toggle(function()
  69. {
  70. var img = $( this ).children()
  71. img.attr( 'src', '/images/maximize_gray.png')
  72. general_block.hide()
  73. },
  74. function()
  75. {
  76. var img = $( this ).children()
  77. img.attr( 'src', '/images/minimize_gray.png')
  78. general_block.show()
  79. }
  80. )
  81.  
  82. show_hide_block.toggle(
  83. function()
  84. {
  85. var el = $( this ).parent().next( '.controls' ),
  86. img = $( this ).children()
  87. img.attr( 'src', '/images/maximize_gray.png')
  88. el.hide()
  89. },
  90. function()
  91. {
  92. var el = $( this ).parent().next( '.controls' ),
  93. img = $( this ).children()
  94. img.attr( 'src', '/images/minimize_gray.png')
  95. el.show()
  96. }
  97. )
  98.  
  99. me.win.bind( 'resize', calc_max_heigth )
  100. //--
  101.  
  102. //onload
  103. //--
  104. return me
  105. }
  106.  
  107. ControllPanel = function( el, params ){
  108. var me = Panel( el, params ),
  109.  
  110. //dom elements
  111. visible_checkbox = me.block_head().children( '.name' ).children( '.tile_layer_visible_checkbox' ),
  112. slider = me.controls().children( '.tile_layer_opacity_slider' ),
  113. move_to_project_center = me.controls().children( '.move_to_project_center' )
  114. //--
  115.  
  116. //GLOBAL
  117. me.check_visible = function( c ){
  118. me.checkbox_by_block_class( c ).attr( 'checked', true ) }
  119.  
  120. me.uncheck_visible = function(c ){
  121. me.checkbox_by_block_class( c ).attr( 'checked', false ) }
  122. //--
  123.  
  124. //bindings
  125. slider.slider({
  126. value: 1,
  127. orientation: "horizontal",
  128. animate: true,
  129. min: 0.2,
  130. max: 1,
  131. step: 0.2,
  132. change: function(event, ui) {
  133. var em = $(this)
  134. if( navigator.appName == 'Microsoft Internet Explorer' ){
  135. $('#YMapsID .' + em.attr('rel') + '_tiles').children().children().css('filter', 'alpha(opacity=' + ui.value * 100 + ')')
  136. }else{
  137. $('#YMapsID .' + em.attr('rel') + '_tiles').css(
  138. {
  139. '-moz-opacity': ui.value,
  140. '-webkit-opacity': ui.value,
  141. opacity: ui.value
  142. }
  143. )
  144. }
  145. }
  146. })
  147.  
  148. move_to_project_center.click( function(){
  149. var em = $( this ),
  150. c=em.attr( 'rel' ).split( ',' )
  151. map.panTo(new YMaps.Point(parseInt( c[ 0 ] ),parseInt( c[ 1 ] )));
  152. return false
  153. } )
  154.  
  155. visible_checkbox.change( function(){
  156. var em = $( this )
  157. if(em.attr('checked')){
  158. map.addLayer(em.attr('rel') + '_tiles')
  159. }else{
  160. map.removeLayer(em.attr('rel') + '_tiles')
  161. }
  162. } )
  163. //--
  164.  
  165. //onload
  166. left = me.from().offset().left
  167. el.css( { left: left, bottom: me.bottom() } )
  168. me.check_visible( '.basic' )
  169. me.init()
  170. //--
  171.  
  172. return me
  173. }
  174.  
  175. SignPanel = function( el, params ){
  176. var me = Panel( el, params )
  177. //dom elements
  178. var empty_sign_panel = me.general_block().children( '.empty_sign_panel' ),
  179. show_tiles_side = empty_sign_panel.children( 'a' ),
  180. //--
  181. show_block = me.show_block,
  182. hide_block = me.hide_block
  183. //GLOBAL
  184. me.show_block = function( c ){
  185. show_block( c )
  186. if(!me.is_all_block_hidden())empty_sign_panel.hide()
  187. }
  188. me.hide_block = function( c ){
  189. hide_block( c )
  190. if(me.is_all_block_hidden())empty_sign_panel.show()
  191. }
  192. me.nav_to_tiles_side_bind = function( func ){
  193. show_tiles_side.click( func )
  194. }
  195. //
  196. //bind
  197. //--
  198. //onload
  199. right = me.win.width() - ( me.from().offset().left + me.from().innerWidth() )
  200. el.css( { right: right, bottom: me.bottom() } )
  201. if(!me.is_all_block_hidden())empty_sign_panel.hide()
  202. me.init()
  203. //--
  204. return me
  205. }
Add Comment
Please, Sign In to add comment