1 From 0df0afd2b03ab688210b9ff71d65dff73a33419c Mon Sep 17 00:00:00 2001
2 From: "hjnim.kim" <hjnim.kim@samsung.com>
3 Date: Tue, 11 Dec 2012 19:14:31 +0900
4 Subject: [PATCH] Apply tizen style context popup
7 libs/js/jquery-mobile-1.2.0/js/widgets/popup.js | 95 ++++++++++++++++++++---
8 1 files changed, 84 insertions(+), 11 deletions(-)
10 diff --git a/libs/js/jquery-mobile-1.2.0/js/widgets/popup.js b/libs/js/jquery-mobile-1.2.0/js/widgets/popup.js
11 index de2af2c..6470bc4 100644
12 --- a/libs/js/jquery-mobile-1.2.0/js/widgets/popup.js
13 +++ b/libs/js/jquery-mobile-1.2.0/js/widgets/popup.js
14 @@ -58,7 +58,7 @@ define( [ "jquery",
15 // https://github.com/jquery/jquery-mobile/issues/4784
17 // NOTE this option is modified in _create!
18 - history: !$.mobile.browser.ie
22 _eatEventAndClose: function( e ) {
23 @@ -109,7 +109,7 @@ define( [ "jquery",
26 _resizeTimeout: function() {
27 - if ( !this._maybeRefreshTimeout() ) {
28 + if ( !this._maybeRefreshTimeout() && this.positionTo === "window" ) {
29 // effectively rapid-open the popup while leaving the screen intact
30 this._trigger( "beforeposition" );
32 @@ -144,7 +144,8 @@ define( [ "jquery",
34 screen: $( "<div class='ui-screen-hidden ui-popup-screen'></div>" ),
35 placeholder: $( "<div style='display: none;'><!-- placeholder --></div>" ),
36 - container: $( "<div class='ui-popup-container ui-selectmenu-hidden'></div>" )
37 + container: $( "<div class='ui-popup-container ui-selectmenu-hidden'></div>" ),
38 + arrow : $("<div class='ui-arrow'></div>")
40 thisPage = this.element.closest( ".ui-page" ),
41 myId = this.element.attr( "id" ),
42 @@ -174,7 +175,7 @@ define( [ "jquery",
43 ui.placeholder.html( "<!-- placeholder for " + myId + " -->" );
45 ui.container.append( this.element );
47 + ui.container.append( ui.arrow );
48 // Add class to popup element
49 this.element.addClass( "ui-popup" );
51 @@ -276,7 +277,7 @@ define( [ "jquery",
54 _setTolerance: function( value ) {
55 - var tol = { t: 30, r: 15, b: 30, l: 15 };
56 + var tol = { t: 5, r: 5, b: 5, l: 5 };
59 var ar = String( value ).split( "," );
60 @@ -361,7 +362,11 @@ define( [ "jquery",
61 cx: winCoords.cx - this._tolerance.l - this._tolerance.r,
62 cy: winCoords.cy - this._tolerance.t - this._tolerance.b
66 + linkOffset = $(this.link).offset(),
67 + positionOffsets = [],
68 + correctionValue = [0,0],
71 // Clamp the width of the menu before grabbing its size
72 this._ui.container.css( "max-width", rc.cx );
73 @@ -388,8 +393,48 @@ define( [ "jquery",
74 docHeight = Math.max( docEl.clientHeight, docBody.scrollHeight, docBody.offsetHeight, docEl.scrollHeight, docEl.offsetHeight );
76 ret.y -= Math.min( ret.y, Math.max( 0, ret.y + menuSize.cy - docHeight ) );
77 + if ( this.positionTo === "window" )
79 + return { left: ret.x, top: ret.y , arrowleft: 0 , arrowtop: 0};
82 + positionOffsets = [ linkOffset.left,
84 + docEl.clientHeight - ( linkOffset.top + $(this.link).height() ),
85 + docEl.clientWidth - ( linkOffset.left + $(this.link).width() )];
86 + arrayIdx = positionOffsets.indexOf(Math.max.apply(window,positionOffsets));
91 + correctionValue = [ -$(this.link).width() , 0];
92 + arrow.attr( "class", "" )
93 + .addClass( "ui-arrow right" );
96 + correctionValue = [ 0 , -(ret.y + menuSize.cy - linkOffset.top)];
97 + arrowtop = menuSize.cy - 1;
98 + arrowleft = (linkOffset.left - ret.x + correctionValue[0]) + ( $(this.link).width() / 2 ) - parseInt( $(this._ui.arrow).css("border-width") ) / 2;
99 + $(this._ui.arrow).attr( "class", "" )
100 + .addClass( "ui-arrow bottom" );
103 + correctionValue = [ 0 , ( linkOffset.top + $(this.link).height() - ret.y ) ];
104 + arrowtop = - parseInt( $(this._ui.arrow).css("border-width") ) * 2 + 1;
105 + arrowleft = (linkOffset.left - ret.x + correctionValue[0]) + ( $(this.link).width() / 2 ) - parseInt( $(this._ui.arrow).css("border-width") ) / 2;
106 + $(this._ui.arrow).attr( "class", "" )
107 + .addClass("ui-arrow top");
110 + correctionValue = [ ( menuSize.cx < $(this.link).width() ) ? ( $(this.link).width() / 2 ) + ( menuSize.cx / 2) : $(this.link).width() , 0];
111 + arrowtop = ( linkOffset.top - ret.y ) + ( $(this.link).height() / 2 ) - parseInt( $(this._ui.arrow).css("border-width") ) ;
112 + arrowleft = - parseInt( $(this._ui.arrow).css("border-width") ) * 2;
113 + $(this._ui.arrow).attr( "class", "" )
114 + .addClass("ui-arrow right");
118 - return { left: ret.x, top: ret.y };
119 + return { left: ret.x + correctionValue[0], top: ret.y + correctionValue[1] , arrowleft: arrowleft , arrowtop: arrowtop };
122 _createPrereqs: function( screenPrereq, containerPrereq, whenDone ) {
123 @@ -569,7 +614,7 @@ define( [ "jquery",
125 .removeClass( "ui-selectmenu-hidden" )
128 + this._ui.arrow.css( { top : coords.arrowtop, left : coords.arrowleft } );
129 if ( this.options.overlayTheme && androidBlacklist ) {
131 The native browser on Android 4.0.X ("Ice Cream Sandwich") suffers from an issue where the popup overlay appears to be z-indexed
132 @@ -587,6 +632,7 @@ define( [ "jquery",
133 // TODO sort out why this._page isn't working
134 this.element.closest( ".ui-page" ).addClass( "ui-popup-open" );
138 additionalCondition: true,
139 transition: transition,
140 @@ -691,15 +737,42 @@ define( [ "jquery",
141 // what should be in _open. Seems to be "visual" vs "history" for now
142 open: function( options ) {
143 var self = this, opts = this.options, url, hashkey, activePage, currentIsDialog, hasHash, urlHistory;
145 + // self.link = ( $(event.target).attr('data-role') === 'button') ? event.target : $(event.target).closest('[data-role="button"]')[0];
146 // make sure open is idempotent
147 if( $.mobile.popup.active ) {
151 // set the global popup mutex
152 $.mobile.popup.active = this;
158 + if ( !options.link )
160 + self.link = $(event.target).closest('a')[0];
162 + self.link = options.link;
164 + self.positionTo = ( options != null && options.positionTo != null ) ? options.positionTo : "origin";
165 + if ( $(self.link).jqmData("position-to") !== "window")
167 + $(self.element).addClass("ui-ctxpopup");
168 + $(self._ui.container).removeClass("ui-popup-container")
169 + .addClass("ui-ctxpopup-container");
171 + $(self._ui.arrow).hide();
174 + && self.positionTo !== "window" )
176 + options.x = $(self.link).offset().left + $(self.link).outerWidth() / 2;
179 + && self.positionTo !== "window" )
181 + options.y = $(self.link).offset().top + $(self.link).outerHeight() / 2;
183 // if history alteration is disabled close on navigate events
184 // and leave the url as is
185 if( !( opts.history ) ) {